// xc_lshop/club/barter/order/list.js
var barter_order = require('../../../model/barter_order')
// var barter_order = require('..')

Page({
  mixins: [require('../../../../../xc/mixins/basicMixin')],

  /**
   * 页面的初始数据
   */
  data: {
    searchmodel:{}
  },
  xcloaddata: function (options, config) {
    var update = {};
    if (config.payment) {
      update["paymentconfig"] = config.payment
    }
    this.setData(update)
    var strwhere = {}
    var that = this
    that.getpagelist(that, 1, strwhere)
  },
  afterlogin: function (options, config, userinfo) {
    
  },
  getpagelist(that, rest, strwhere) {
    if (rest == 1) {
      strwhere = this.data.searchmodel;
      // if(!strwhere)
      // {
      //   strwhere={}
      // }
      // strwhere["status"] = this.data.activetab
      that.setData({
        modellist: [],
        isempty: false
      });
    }
    barter_order.offset(that, rest, strwhere).then(function (result) {
      var updatemodel = {};
      if ((result["code"] == "over" && result["obj"]) || result["code"] == "loadmore") {
        if (result["obj"]["modellist"].length < 1 && that.data.modellist.length < 1) {
          updatemodel["isempty"] = true
        } else if (rest == 1) {
          updatemodel["modellist"] = result["obj"]["modellist"];
        } else {
          if (result["obj"]["modellist"].length > 0) {
            updatemodel["modellist"] = that.data.modellist.concat(result["obj"]["modellist"]);
          }
        }
      }
      // that.selectComponent("#ordercomment").showmodel( updatemdoel["modellist"][0],"order")      
      wx.stopPullDownRefresh();
      that.setData(updatemodel);
    }, function () {

    });
  },
  btnop(e){
    console.log(e)
    var op=e.detail.op;
    if(op==1){  
      wx.navigateTo({
        url: '/xc_lshop/club/barter/pro/index?clubid='+this.data.clubinfo.id+'&ordernum='+e.detail.ordernum,
      })
    }else{
      this.pageback()
    }

  },
  showfail(e){
    var that=this;
    var reason=e.currentTarget.dataset.reason;
    var ordernum=e.currentTarget.dataset.ordernum;

    that.selectComponent("#examstatus").init(-1,reason,ordernum)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    var that = this
    that.getpagelist(that, 1)
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    var that = this
    that.getpagelist(that, -1)
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})